<!DOCTYPE html>
<html lang="en">
<!--
	作者：张佳齐
	时间：2019-05-29
	描述：数据字典表的添查修改
-->
	<head>
		<meta charset="UTF-8">
		<title>数据字典</title>
		<link rel="stylesheet" href="../../../js/bower_components/bootstrap/dist/css/bootstrap.min.css">
		<link rel="stylesheet" href="../../../js/bower_components/bootstrap-select/dist/css/bootstrap-select.min.css">
		<link rel="stylesheet" href="../../../js/bower_components/bootstrap-switch/dist/css/bootstrap3/bootstrap-switch.min.css">
		<link rel="stylesheet" href="../../../js/bower_components/bootstrap-table/dist/bootstrap-table.min.css">
		<link rel="stylesheet" href="../../../js/bower_components/bootstrap-treeview/dist/bootstrap-treeview.min.css">

		<script src="../../../js/bower_components/jquery/dist/jquery.min.js"></script>
		<script src="../../../js/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
		<script src="../../../js/bower_components/bootbox.min.js"></script>
		<script src="../../../js/bower_components/bootstrap-select/js/bootstrap-select.js"></script>
		<script src="../../../js/bower_components/bootstrap-switch/dist/js/bootstrap-switch.min.js"></script>
		<script src="../../../js/bower_components/bootstrap-table/dist/bootstrap-table.min.js"></script>
		<script src="../../../js/bower_components/bootstrap-table/dist/locale/bootstrap-table-zh-CN.js"></script>

		<script src="../../../js/bower_components/bootstrap-treeview/dist/bootstrap-treeview.min.js"></script>
		<script src="../../../js/bower_components/jquery-form-validator/form-validator/jquery.form-validator.min.js"></script>
		<script src="../../../js/bower_components/moment/min/moment-with-locales.min.js"></script>
		<script>
			var temp_did = 0;
			$(function() {
				$.ajax({
					type: "get",
					url: "http://127.0.0.1:8080/getAllD",
					dataType: "json",
					contentType: "application/json;charset=utf-8",
					success: function(data) {
						console.log(data);
						console.log(data.data.list)
						CreateDataTable(data.data.list)
					}
				});
//				CreateUserTable("");
				//新增数据
				$("#butAdd").click(function() {
					alert("ssss")
					$("#divData").modal();
				});
				//保存数据
				$("#btnSave").click(function() {
					var did = $("#txtDatadid").val();
					var datado = $("#txtDataDo").val();
					var dp1 = $("#txtDatatp1").val();
					var createt = $("#txtLoanCreatet").val();
					var updatet = $("#txtLoanUpdatet").val();
					var createp = $("#txtLoanCreatep").val();
					var updatep = $("#txtLoanUpdatep").val();
					var str = '{"createp": "'+createp+'","createt": "'+createt+'","dataitinfo": "'+datado+'","datatp": "'+dp1+'","did": '+did+',"updatep": "'+updatep+'","updatet": "'+updatet+'"}'
					console.log(str);
					$.ajax({
						type: "put",
						url: "http://127.0.0.1:8080/addD",
						data: str,
						dataType: "json",
						contentType: "application/json;charset=utf-8",
						success: function(data) {
							console.log(data);
							if(data == 1) {
								$.ajax({
									type: "get",
									url: "http://127.0.0.1:8080/getAllD",
									dataType: "json",
									contentType: "application/json;charset=utf-8",
									success: function(data) {
										CreateDataTable(data.data.list);
										emptyData();
									}
								});
							}

						}
					});
				})
////				//删除数据
				$("#butDel").click(function() {
					var did = temp_did;
					alert("确认删除角色的主键是：" + did)
					$.ajax({
						type: "get",
						url: "http://127.0.0.1:8080/delD",
						data: "did=" + did,
						dataType: "json",
						contentType: "application/json;charset=utf-8",
						success: function(data) {
							alert(data);
							if(data == 1) {
								$.ajax({
									type: "get",
									url: "http://127.0.0.1:8080/getAllD",
									dataType: "json",
									contentType: "application/json;charset=utf-8",
									success: function(data) {
										CreateDataTable(data.data.list)
									}
								});
							} else {
								alert("删除失败")
							}
						}
					});
				});
//				//修改数据之前获取数据的方法
//				$("#butEdit").click(function() {
//					var uid = temp_uid;
//					if(uid > 0) {
//						$.ajax({
//							type: "get",
//							url: "http://127.0.0.1:8080/getAll",
//							data: "uid=" + uid,
//							dataType: "json",
//							contentType: "application/json;charset=utf-8",
//							success: function(data) {
//								alert(data);
//								if(data != null) {
//									$("#divData").modal();
//									$("#txtUseruid").val(data.uid);
//									$("#txtUseruid").attr("readonly", "true");
//									$("#txtUserName1").val(data.uname);
//									console.log()
//									$("#seluisbegin1").selectpicker('val', data.uibegin);
//								} else {
//									alert("删除失败")
//								}
//							}
//						});
//					}
//				})
			});


			//对放款列表加载动态数据
			function CreateDataTable(data) {
				//			console.log("进入绑定事件"+data)
				$("#tabData").bootstrapTable("destroy");
				$("#tabData").bootstrapTable({
					loadMsg: "数据正在加载中....",
					uniqueId: "did", //绑定列表主键（数据库主键）
					pageSize: 5,
					pagination: true,
					idFied: "did",
					onClickRow: function(row) {
						alert(row.did);
						temp_did = row.did;
					},
					data: data,
					columns: [{
						field: "did",
						title: "主键"
					}, {
						field: "dataitinfo",
						title: "数据信息项"
					}, {
						field: "datatp",
						title: "数据类型"
					},  {
						field: "createt",
						title: "创建时间"
					},{
						field: "updatet",
						title: "更新时间"
					}, {
						field: "createp",
						title: "创建人"
					}, {
						field: "updatep",
						title: "更新人"
					}]
				});
			}
				//给下拉框绑定json数据


			//清空表单数据
			function emptyData() {
				$("#txtDatadid").val("");
				$("#txtDataDo").val("");
				$("#txtDatatp1").val("");
				$("#txtLoanCreatet").val("");
				$("#txtLoanUpdatet").val("");
				$("#txtLoanCreatep").val("");
				$("#txtLoanUpdatep").val("");
			}
		</script>

	</head>

	<body>
		<div class="container-fluid">
			<!--查询区域-->
			<div class="row col-md-10">
				<div class="form-inline">
					<div class="form-group">
						<label class="control-label" for="txtDatatp">数据类型</label>
						<input class="form-control" id="txtDatatp" />
					</div>
					<div class="form-group">
						<button type="button" class="btn btn-primary">查询</button>
					</div>
				</div>
			</div>
			<br /><br /><br />
			<!--功能区域-->
			<div class="row col-md-10">
				<div>
					<button type="button" id="butAdd" class="btn btn-success">新增</button>
					<button type="button" id="butEdit" class="btn btn-info">修改</button>
					<button type="button" id="butDel" class="btn btn-danger">删除</button>
				</div>
			</div>
			<br /><br /><br />
			<!--列表区域-->
			<div class="row col-md-10">
				<table id="tabData"></table>
			</div>
			<!--表单区域-->
			<div class="modal fade" id="divData" tabindex="1">
				<div class="modal-dialog" style="width: 500px;">
					<div class="modal-content">
						<div class="modal-header">
							<h4 class="modal-title">新增数据信息</h4>
						</div>
						<div class="modal-body form-inline">
							<div class="form-group">
								<label class="control-label">主键</label>
								<input type="number" maxlength="20" class="from-control" id="txtDatadid" />
							</div>
							<br />	<br />
							<div class="form-group">
								<label class="control-label">数据项信息</label>
								<input type="text" maxlength="20" class="from-control" id="txtDataDo" />
							</div>
							<br />	<br />
							<div class="form-group">
								<label class="control-label">数据类型</label>
								<input type="text" maxlength="20" class="from-control" id="txtDatatp1" />
							</div>
							<br />	<br />
							<div class="form-group">
								<label class="control-label">创建时间</label>
								<input type="date" maxlength="20" class="from-control" id="txtLoanCreatet" />
							</div>
							<br />	<br />
							<div class="form-group">
								<label class="control-label">更新时间</label>
								<input type="date" maxlength="20" class="from-control" id="txtLoanUpdatet" />
							</div>
							<br />	<br />
							<div class="form-group">
								<label class="control-label">创建人</label>
								<input type="text" maxlength="20" class="from-control" id="txtLoanCreatep" />
							</div>
							<br />	<br />
							<div class="form-group">
								<label class="control-label">更新人</label>
								<input type="text" maxlength="20" class="from-control" id="txtLoanUpdatep" />
							</div>
							<br />	<br />
							<div class="modal-footer">
								<button type="button" class="btn btn-success" id="btnSave" data-dismiss="modal">保存</button>
								<button type="button" class="btn btn-primary" id="btnClose" data-dismiss="modal">取消</button>
							</div>
							<br />	<br />
						</div>
					</div>
				</div>
			</div>
		</div>

	</body>

</html>
